<?php

// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库：https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库：https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------

namespace app\store\controller;

use library\Controller;
use library\tools\Data;
use think\Db;
use app\store\model\Common;
/**
 * 通信记录
 * Class Documentlist
 * @package app\store\controller
 */
class Dev extends Controller
{
    /**
     * 指定数据表
     * @var string
     */
    protected $table = 'Dev';
    protected $table1 = 'dev';

    /**
     * 通信记录
     * @auth true
     * @menu true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $this->title = '通信记录';
        $query = $this->_query($this->table)->like("device_sn");
        $query->order('id desc')->page();
    }

    /**
     * 数据列表处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    protected function _index_page_filter(&$data)
    {
        foreach ($data as &$vo) {
            if($vo['bin_code']=='02'){
                $vo['bin_code'] = '<span style="color: green;font-weight: bold">02、登录认证应答</span>';
            }
            if($vo['bin_code']=='04'){
                $vo['bin_code'] = '<span style="color: orangered;font-weight: bold">04、心跳包应答</span>';
            }
            if($vo['bin_code']=='06'){
                $vo['bin_code'] = '<span style="color: yellowgreen;font-weight: bold">06、计费模型验证请求应答</span>';
            }
            if($vo['bin_code']=='0A'){
                $vo['bin_code'] = '<span style="color: yellowgreen;font-weight: bold">0A、计费模型请求应答</span>';
            }

            if($vo['bin_code']=='13'){
                $vo['bin_code'] = '<span style="color: red;font-weight: bold">13、离线监测数据</span>';
            }
            if($vo['bin_code']=='33'){
                if($vo['jieguo']==00){ $vo['jieguo']='失败';}
                if($vo['jieguo']==01){ $vo['jieguo']='成功';}

                if($vo['reason']==00){ $vo['reason']='成功';}
                if($vo['reason']==01){ $vo['reason']='设备编号不匹配';}
                if($vo['reason']==02){ $vo['reason']='枪已在充电';}
                if($vo['reason']==03){ $vo['reason']='设备故障';}
                if($vo['reason']==04){ $vo['reason']='设备离线';}
                if($vo['reason']==05){ $vo['reason']='未插枪';}
                $vo['bin_code'] = '<span style="color: blue;font-weight: bold">33、远程启机命令回复</span>';
            }
            if($vo['bin_code']=='34'){
                $vo['bin_code'] = '<span style="color: dodgerblue;font-weight: bold">34、运营平台远程控制启机</span>';
            }

            if($vo['bin_code']=='35'){
                if($vo['jieguo']==00){ $vo['jieguo']='失败';}
                if($vo['jieguo']==01){ $vo['jieguo']='成功';}

                if($vo['reason']==00){ $vo['reason']='成功';}
                if($vo['reason']==01){ $vo['reason']='设备编号不匹配';}
                if($vo['reason']==02){ $vo['reason']='枪未处于充电状态';}
                if($vo['reason']==03){ $vo['reason']='其他';}
                $vo['bin_code'] = '<span style="color: #ee218b;font-weight: bold">35、远程停机命令回复</span>';
            }
            if($vo['bin_code']=='36'){
                $vo['bin_code'] = '<span style="color: #ee208b;font-weight: bold">36、运营平台远程停机</span>';
            }

            if($vo['bin_code']=='3B'){
                $vo['bin_code'] = '<span style="color: #000;font-weight: bold">3B、交易记录</span>';
            }

            if($vo['bin_code']=='40'){
                $vo['bin_code'] = '<span style="color: #000;font-weight: bold">40、交易记录确认</span>';
            }

        }


    }



}
